package vistajuego.dibujos;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.Frame;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.Toolkit;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

import vistajuego.BaseVista;

public class Ventana extends Frame implements BaseVista {
	
	private Image imagen;
	
	public void update(Graphics grafico){
		paint(grafico);
	}

	public void paint(Graphics grafico ){
		grafico.drawImage(this.imagen,8,28,null);
	}
	
	public void limpiar() {
		if(this.imagen == null)
			this.imagen = this.createImage(getSize().width, getSize().height);
		Graphics ventanaBase =  this.imagen.getGraphics();
		ventanaBase.setColor(Color.WHITE);// 
		ventanaBase.fillRect(0, 0, this.getSize().width, this.getSize().height);		
	}
	
	public void actualizar(){
		this.repaint();
	}
	
	public Ventana(int ancho,int alto) {
		setSize(ancho, alto);
		Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
		Dimension frameSize = getSize();
		int x = (screenSize.width - frameSize.width) / 2;
		int y = (screenSize.height - frameSize.height) / 2;
		setLocation(x, y);
		addWindowListener(new WindowAdapter() {
			public void windowClosing(WindowEvent e) {
				dispose();
				System.exit(0);
				}
			});
	}
	private static final long serialVersionUID = 1L;
	
}




